package com.nineclock.common.exception;

import com.nineclock.common.entity.Result;
import com.nineclock.common.enums.ResponseEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class BaseExceptioHandler {


    @ExceptionHandler(value = NcException.class)
    public Result ncException(NcException e) {
        return Result.errorMessage(ResponseEnum.SERVER_ERROR.getMessage());
    }

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result except(Exception e) {
        return Result.errorMessage(e.getMessage());
    }
}
